<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>证书管理系统配置</title>
    <link rel="stylesheet" href="https://tstatic.dgg.net/static/plugs/DataTables/css/jquery.dataTables.css">
    <link rel="stylesheet" href="https://tstatic.dgg.net/static/plugs/layui/css/layui.min.css">
    <link rel="stylesheet" href="https://tstatic.dgg.net/static/css/dgg-iboss.min.css">
    <link rel="stylesheet" href="https://tstatic.dgg.net/static/css/dgg-plugs.min.css">
    <link rel="stylesheet" href="../../css/aptitudes.min.css">
</head>
<body>
<div class="body-main">
    <div class="titleSearch">
        <div class="layui-inline">
            <label>事业部：</label>
            <div class="layui-input-inline">
                <select class="select-style" name="businessOrganizationId">
                    <option>全部</option>
                    <option value="1">成都资质事业部</option>
                    <option value="2">重庆资质事业部</option>
                    <option value="3">广州资质事业部</option>
                    <option value="4">北京资质事业部</option>
                    <option value="5">武汉资质事业部</option>
                    <option value="6">深圳资质事业部</option>
                    <option value="7">杭州资质事业部</option>
                </select>
            </div>
        </div>
        <div class="layui-inline">
            <button class="layui-btn layui-btn-mini layui-btn-normal">搜索</button>
            <button class="layui-btn layui-btn-mini layui-btn-primary">清空</button>
        </div>
    </div>
    <div class="table-conter">
        <a href="javascript:void(0)" class="layui-btn layui-btn-mini" onclick="addConfiguration()">新增配置</a>
    </div>

    <table id="myTable" class="cell-border crm-table">
    </table>
</div>
<!--复制指导价 弹窗 start-->
<div  class="content-layer layui-layer-wrap" id="addConfiguration">
    <table class="add-table form-table">
        <tbody>
        <tr>
            <th><span class="required">所属事业部：</span></th>
            <td>
                <select class="select-style" name="businessOrganizationId">
                    <option>全部</option>
                    <option value="1">成都资质事业部</option>
                    <option value="2">重庆资质事业部</option>
                    <option value="3">广州资质事业部</option>
                    <option value="4">北京资质事业部</option>
                    <option value="5">武汉资质事业部</option>
                    <option value="6">深圳资质事业部</option>
                    <option value="7">杭州资质事业部</option>
                </select>
            </td>
        </tr>
        </tbody>
    </table>
</div>
<!--复制指导价 弹窗 end-->
<script src="https://tstatic.dgg.net/static/plugs/jquery/jquery-1.9.1.min.js"></script>
<script src="https://tstatic.dgg.net/static/plugs/layui/layui.all.js"></script>
<script src="https://tstatic.dgg.net/static/plugs/DataTables/js/jquery.dataTables.js"></script>
<script src="https://tstatic.dgg.net/static/plugs/DataTables/js/dataTables.fixedColumns.min.js"></script>
<script src="https://tstatic.dgg.net/static/plugs/DataTables/js/dataTable.extend.js"></script>
<script src="https://tstatic.dgg.net/static/js/dgg-foot-base.js"></script>
<script>
    var manageTableObj;
    $(function () {
        manageTableObj=$('#myTable').dataTableExtend({
            "ajax": "https://www.easy-mock.com/mock/5b601a98e5570610098cc81f/interface/table.co",
//			    	"select":true,
            "scrollX":"true",//是否开启横项滚动
            "fixedColumns":   {//锁定列，只有开启scrollX时才生效
                "leftColumns": 2,//左侧锁定2列
                "rightColumns": 1//右侧锁定1列
            },
            "aoColumns": [
                {
                    "title":"序号",
                    "render": function (data, type, full, meta) {
//			                    console.log(meta.row);
                        return meta.row+1;
                    }
                },
                {
                    "title":"所属事业部",
                    "data": "businessOrganizationId",
                    "orderable": false
                },
                {
                    "title":"资金池预警值（元）",
                    "data": "createTime",
                    "orderable": false,
                    "render":function (data, type, full, meta) {
                        return '<div class="operability-td line-edit">' +
                            '<input type="text"  readonly value="'+data+'" name="n1"/>' +
                            '</div>';
                    }
                },
                {
                    "title":"库容预警值（个）",
                    "data": "no",
                    "orderable": false,
                    "render":function (data, type, full, meta) {
                        return '<div class="operability-td line-edit">' +
                            '<input type="text" readonly value="'+data+'" name="n2"/>' +
                            '</div>';
                    }
                },
                {
                    "title":"证书过期预警值（天）",
                    "data": "createrName",
                    "orderable": false,
                    "render":function (data, type, full, meta) {
                        return '<div class="operability-td line-edit">' +
                            '<input type="text" readonly value="'+data+'" name="n3"/>' +
                            '</div>';
                    }
                },
                {
                    "title":"证书使用预警值（天）",
                    "data": "lastFollowRecordUser",
                    "orderable": false,
                    "render":function (data, type, full, meta) {
                        return '<div class="operability-td line-edit">' +
                            '<input type="text" readonly value="'+data+'" name="n4"/>' +
                            '</div>';
                    }
                },
                {
                    "title":"证书未使用预警值（天）",
                    "data": "originType",
                    "orderable": false,
                    "render":function (data, type, full, meta) {
                        return '<div class="operability-td line-edit">' +
                            '<input type="text" readonly value="'+data+'" name="n5"/>' +
                            '</div>';
                    }
                },
                {
                    "title":"人才合同到期预警值（天）",
                    "data": "createTime",
                    "orderable": false,
                    "render":function (data, type, full, meta) {
                        return '<div class="operability-td line-edit">' +
                            '<input type="text" readonly value="'+data+'" name="n6"/>' +
                            '</div>';
                    }
                },
                {
                    "title":"企业合同到期预警值（天）",
                    "data": "lastFollowRecordContent",
                    "orderable": false,
                    "render":function (data, type, full, meta) {
                        return '<div class="operability-td line-edit">' +
                            '<input type="text"  readonly value="'+data+'" name="n7"/>' +
                            '</div>';
                    }
                },
                {
                    "title":"最新操作时间",
                    "data": "createTime",
                    "orderable": false
                },
                {
                    "title":"最新操作人",
                    "data": "lastFollowRecordUser",
                    "orderable": false
                },
                {
                    "title":"操作",
                    "orderable": false,
                    "data": "lastFollowRecordUser",
                    "render":function (data, type, full, meta) {
                        // console.log(meta)
                        return '<a href="javascript:void(0)" class="iboss-link" onclick="editManage($(this),'+meta.row+')">编辑</a>'
                    }
                }
            ],
        });
    });
    function editManage(obj,i) {
        console.log(obj.parents('.dataTables_wrapper').length)
        var saveHtm='<a href="javascript:void(0)" class="iboss-link" onclick="saveManage($(this),'+i+')">保存</a>'
        obj.parents('.dataTables_wrapper').find('#myTable tbody>tr').eq(i).find('.operability-td input').addClass('input-style').removeAttr('readonly');
        obj.parent().append(saveHtm);
        obj.remove();
    }
    function saveManage(obj,i) {
        var editHtm='<a href="javascript:void(0)" class="iboss-link" onclick="editManage($(this),'+i+')">编辑</a>';
        obj.parents('.dataTables_wrapper').find('#myTable tbody>tr').eq(i).find('.operability-td input').removeClass('input-style').attr('readonly','readonly');
        var saveDate={};
        var rowIndex=obj.parents('.dataTables_wrapper').find('#myTable tbody>tr').eq(i);
        rowIndex.find('td').each(function () {
            var idx=manageTableObj.cell( this ).index().column;
            var name=manageTableObj.column( idx ).dataSrc();
            var isEdit=$(this).find('.operability-td').length;
            if(isEdit!=0) {
                var  value=$(this).find('.operability-td input').val();
                saveDate[name]=value;
            }
        });
        console.log( manageTableObj.rows(rowIndex).data())
        obj.parent().append(editHtm);
        obj.remove();
        //    向后台保存编辑后的数据，再刷新table
    }
    //新增配置
    function addConfiguration() {
        dgg.Open({
            title: '新增配置',
            content: $('#addConfiguration'),
            area: '480px',
        })
    }
</script>
</body>
</html>